<?
exit;
include_once("/var/www/html/new/com.inc.php");// 公用头部
include_once('/var/www/html/new/d/shops/nav.cfg.php');
// include_once("/var/www/html/new/conf/yd.le.je");//连接云顶的数据库
// include_once("/var/www/html/new/d/common/yd.le.je");//连接云顶的数据库
define('CLIENT_PATH','http://www.12301.cc/yd/client');
define('YD_PATH','http://www.12301.cc/yd');
// $ydle=new yd_go_sql();
// $ydle->connect();

// 通过二级域名找到该域名绑定账户
$host = str_replace('www.', '', $_SERVER['HTTP_HOST']);
$applyAccount   = substr($host, 0, strpos($host, '12301')-1);
echo $applyAccount;
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis_key      = "shop_{$applyAccount}";
//$redis->delete($redis_key);
$shop           = $redis->get($redis_key);
//print_r($shop);
if (!$shop) {
    $sql = <<<SQL
SELECT `fid`,`M_domain`, `M_name`, `M_logo1`, `M_logo2`, `M_banner`,
`M_banner_url`, `M_navi`, `M_qq`, `M_tel`, `M_host`,`M_addr`
FROM pft_member_domain_info WHERE M_domain='{$applyAccount}' LIMIT 1
SQL;
    echo $sql;
    $GLOBALS['le']->query($sql);
    $shop = $GLOBALS['le']->fetch_assoc();
    if ($shop) {
        $redis->setex($redis_key, 1800, serialize($shop));
    }
}
else {
    $shop = unserialize($shop);
}
if(!isset($_SESSION['domain_mid'])){
    $_SESSION['domain_mid'] = $shop['fid'];
}
define('APPLY_DID', $_SESSION['domain_mid']);
echo APPLY_DID;
if(!APPLY_DID)exit('非法访问');
?>
